package com.sfac.day02.modules.test.controller;

import com.sfac.day02.modules.common.entity.ResultBean;
import com.sfac.day02.modules.test.entity.Country;
import com.sfac.day02.modules.test.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class CountryController {
    @Autowired
    private CountryService countryService;
    /**
     * 127.0.0.1/api/country/522 ---- get
     */
    @GetMapping("/country/{countryId}")
    public ResultBean<Country> getCountryByCountryId(int countryId){
        return countryService.getCountryByCountryId(countryId);
    }
    /**
     * 127.0.0.1/api/country?countryName=China ---- get
     */
    @GetMapping("/country")
    public ResultBean<Country> getCountryByCountryName(String countryName){
        return countryService.getCountryByCountryName(countryName);
    }

}
